const db = require('./DB')
const getHouseList = () => {
  return new Promise((resolve, reject) => {
    let sql = `SELECT * FROM houses`
    db.query(sql, (err, results) => {
      if (err) {
        return reject(err)
      }
      resolve(results)
    })
  })
}
const createHouse = (house) => {
  return new Promise((resolve, reject) => {
    let sql =
      'INSERT INTO `houses`(`title`, `description`, `price`, `area`, `bedrooms`, `bathrooms`, `address`, `city`, `state`, `zip_code`, `country`, `latitude`, `longitude`, `construction_year`, `property_type`, `ownership`, `amenities`, `status`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'
    db.query(sql, house, (err, results) => {
      if (err) {
        return reject(err)
      }
      resolve(results)
    })
  })
}
module.exports = {
  createHouse,
  getHouseList,
}
